<?php
class Setting extends AppModel {
    
    public $name = 'Setting';
    public $useTable = 'setting';
    
    /**
     *
     * @param type $name
     * @return type 
     */
    public function getSettingValue($name){
        $result = $this->find('first',array('conditions' => array('name' => $name)));
        if($result)
            return $result['Setting']['value'];
        return $result;
    }
    
    /**
     *
     * @param type $data 
     */
    public function saveSetting($data){
        $result = $this->find('first',array('conditions' => array('name' => $data['name'])));
        
        if($result)
            $this->id = $result['Setting']['id'];
        
        $this->save(array('Setting' => $data));
    }
    
}
